package com.mk.common.util;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.net.Socket;
import java.util.Scanner;

public class DemoClient
{
	public static void main(String[] args) throws Exception
	{
		Socket socket = new Socket(BasicConstants.HOST_ADDRESS,BasicConstants.NET_PORT);
		
		DataInputStream inputStream = new DataInputStream(socket.getInputStream());
		DataOutputStream outputStream = new DataOutputStream(socket.getOutputStream());
		
		//输入
		Scanner scanner = new Scanner(System.in);
		System.out.println("输入发送信息......");
		String msg = scanner.nextLine();
		
		//发送
		outputStream.writeUTF(msg);
		outputStream.flush();
		//接受返回
		String detail = inputStream.readUTF();
		System.out.println("------服务器返回-----: "+detail);
		
		//关闭资源
		scanner.close();
		socket.close();
	}
}
